package lx;

import java.io.*;
import java.util.TreeSet;

/*
       需求：把《出师表》的文章顺序进行恢复到一个新文件中。
  */
public class demo2Case1 {
    public static void main(String[] args) throws IOException {
        //1.读取数据
        BufferedReader br = new BufferedReader(new FileReader("a.txt"));

        //2.自动排序
        TreeSet<String> ts = new TreeSet();
        String s;
        while ((s = br.readLine()) != null) {
            ts.add(s);

        }
        br.close();
        //3.写出数据
        BufferedWriter bw = new BufferedWriter(new FileWriter("b.txt"));
        for (String t : ts) {
            bw.write(t);
            bw.newLine();
        }
        bw.close();



    }
}
